﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;

namespace IveelySE.Dream.Common.Transmission
{
    /// <summary>
    /// 客户端信息处理
    /// </summary>
    public class ClientProcessor
    {
        /// <summary>
        /// TCP客户端
        /// </summary>
        private TcpClient tcpClient;

        /// <summary>
        /// 客户端连接服务端
        /// </summary>
        /// <param name="server">服务端IP地址</param>
        /// <param name="port">服务端端口号</param>
        public void Connect(string server, int port)
        {
            ClientHelper.ConnectSocket(ref tcpClient, server, port, new AsyncCallback(new ClientHelper().DoReading));
        }

        /// <summary>
        /// 客户端发送信息
        /// </summary>
        /// <param name="data">客户端发送的数据</param>
        public void Send(string data)
        {
            ClientHelper.SendObjectMessage(tcpClient, data);
        }
    }
}
